package com.qgs.secsgem.mq.secsgem;


import com.alibaba.fastjson.JSONObject;
import com.qgs.secsgem.mq.entity.MQMessage;
import com.qgs.secsgem.mq.entity.common.Header;
import com.qgs.secsgem.mq.entity.common.Returns;
import com.qgs.secsgem.mq.entity.specificBody.QueryEQStatusBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2021/8/17 14:35
 */
public class Main {

    public static void main(String[] args) throws Exception {

        new Thread(()->{
            MQMessage mqMessage = new MQMessage();

            Header header = new Header("Request","Execute","QUERYEQPStatus","12");
            QueryEQStatusBody queryEQStatusBody = new QueryEQStatusBody();
            queryEQStatusBody.setVidType("u4");
            List<String> vids = new ArrayList<>();
            vids.add("10000");
            vids.add("10001");
            vids.add("10002");
            queryEQStatusBody.setVidList(vids);
            mqMessage.setBody(JSONObject.toJSONString(queryEQStatusBody));
            mqMessage.setHeader(header);

            AsyncFuture<MQMessage> add = SendedList.add(header.getTransactionId(),mqMessage);
            try {
                MQMessage mqMessageResponse = add.get(new Long(3000));
                System.out.println(mqMessageResponse.getReturns().getReturnCode());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();

        Thread.sleep(1000);

        new Thread(()->{
            MQMessage mqMessage = new MQMessage();
            mqMessage.setReturns(new Returns("233","2"));
            SendedList.set("11221",mqMessage);
        }).start();
    }
}
